menuItems = new Array("home", "instroduction", "service", "myGroup", "contact");
members = new Array("designer1", "designer2", "marketing1", "marketing2", "pro1", "pro2", "pro3", "pro4");

$(document).ready(function() {
	$('li[value=0] a').addClass('active');
	center();
	showContent('home', menuItems);
	
	$('#navigation li').click(function(){
		var selectedValue = $(this).attr('value');
		for(var i = 0; i <= 4; i++){
			if(selectedValue == i) $('li[value='+i+'] a').addClass('active');
			else $('li[value='+i+'] a').removeClass('active');
		}
	});
	
});

function randomlySelectProfile(){
	for(var i = 0; i < members.length; i++){
		var lastIndex = members[i].substring(members[i].length - 1, members[i].length);
		var idElement = members[i].substring(0, members[i].length - 1);
		
		$('#' + members[i] + '').css('display', 'none');
		$('#' + idElement + 'Img' + lastIndex).addClass('pointer');
		$('#' + idElement + 'Img' + lastIndex).removeClass('active');
	}
	
	var n = Math.random() * 10;
	if(n < 0) n = 1;
	else if (n > 7) n = 7;
		
	var randomIndex = Math.abs(Math.floor(n));
	var lastIndex = members[randomIndex].substring(members[randomIndex].length - 1, members[randomIndex].length);
	var idElement = members[randomIndex].substring(0, members[randomIndex].length - 1);
	
	$('#' + idElement + 'Img' + lastIndex).addClass('active');
	$('#' + members[randomIndex] + '').css('display', 'block');
}

function showContent(id, arrays){
	for(var i = 0; i < arrays.length; i++){
		var lastIndex = arrays[i].substring(arrays[i].length - 1, arrays[i].length);
		var idElement = arrays[i].substring(0, arrays[i].length - 1);
		if(id == arrays[i]) { 
			$('#' + arrays[i] + '').css('display', 'block'); 
			$('#' + idElement + 'Img' + lastIndex).addClass('active');
		}
		else {
			$('#' + arrays[i] + '').css('display', 'none');
			$('#' + idElement + 'Img' + lastIndex).removeClass('active');
		}
	}
}

function showContentMenuItem(id){
	for(var i = 0; i < menuItems.length; i++){
		if(id == menuItems[i]) { $('#' + menuItems[i] + '').css('display', 'block'); }
		else $('#' + menuItems[i] + '').css('display', 'none');
	}
}

function changeBackground(oldId, oldPath){
	$('#' + oldId).css('background', 'url(" + oldPath + ")');
//	$('#' + newId).css('background', 'url(' + newPath + ')');
}

function center(){
	window.scrollTo(($('#wrapper').width() / 2) - (screen.width / 2), 
					($('#wrapper').height() / 2) - (screen.height / 2.5));
}
//$(window).resize(function() {
	//($(document).width() / 2) - ($('#wrapperContent').width() / 2), ($(document).height() / 2) - ($('#wrapperContent').height() / 2);
//});